#include "../Include/BitmapAlpha.h"

BitmapAlpha::BitmapAlpha( HINSTANCE hAppInst, const CHAR *pImageFileName, const BYTE alpha /*= 255*/, HDC spriteDC /*= NULL*/, const UINT colorKey /*= RGB( 255, 0, 255 )*/, const PositionType posType /*= POS_UPPER_LEFT*/, const BlendOptions bOp /*= BLEND_SRC_COPY*/ )
	: BitmapMasked( hAppInst, pImageFileName, colorKey, posType, bOp )
{
	m_bFunc.AlphaFormat			= 0;
	m_bFunc.BlendFlags			= 0;
	m_bFunc.BlendOp				= AC_SRC_OVER;
	m_bFunc.SourceConstantAlpha = alpha;
}

void BitmapAlpha::Render( HDC hBBDC, HDC hSprDC, INT x, INT y )
{
	HGDIOBJ oldObj = SelectObject( hSprDC, m_hBitmap );
	LONG w = GetWidth();
	LONG h = GetHeight();

	TranslatePosition( x, y );

	AlphaBlend( hBBDC, x, y, w, h, hSprDC, 0, 0, w, h, m_bFunc );

	SelectObject( hSprDC, oldObj );
}

void BitmapAlpha::Render( HDC hBBDC, HDC hSprDC, INT x, INT y, INT w, INT h, INT srcX, INT srcY )
{
	HGDIOBJ oldObj = SelectObject( hSprDC, m_hBitmap );

	TranslatePosition( x, y );

	AlphaBlend( hBBDC, x, y, w, h, hSprDC, srcX, srcY, w, h, m_bFunc );

	SelectObject( hSprDC, oldObj );
}

